/**************************************************************************
** Yabet is bloging editor tool that supports many blog's formats. It is very usefull for crossposting, allows easily to
** make posts to your blogs.
**
** Copyright (C) 2010 Valery Konchin <eeexception@gmail.com>
**
** This program is free software: you can redistribute it and/or modify
**     it under the terms of the GNU General Public License as published by
**     the Free Software Foundation, either version 3 of the License, or
**     (at your option) any later version.
**
**     This program is distributed in the hope that it will be useful,
**     but WITHOUT ANY WARRANTY; without even the implied warranty of
**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**     GNU General Public License for more details.
**
**     You should have received a copy of the GNU General Public License
**     along with this program.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#include "uploadsplash.h"
#include "ui_uploadsplash.h"
#include <QTimer>

UploadSplash::UploadSplash(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::UploadSplash)
{
    ui->setupUi(this);
}

UploadSplash::~UploadSplash()
{
    delete ui;
}

void UploadSplash::changeEvent(QEvent *e)
{
    QDialog::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void UploadSplash::startShow() {
    this->show();

    this->ui->progressBar->setRange(0, 100);
    this->ui->progressBar->reset();
}

void UploadSplash::stopShow() {
    this->ui->progressBar->reset();

    this->hide();
}

void UploadSplash::updateProgressBar(qint64 bytesSent, qint64 bytesTotal) {
    int position = (int) bytesSent * 100 / bytesTotal;

    ui->progressBar->setValue(position);

//    if(ui->progressBar->value() == ui->progressBar->maximum()) {
//        ui->progressBar->reset();
//        return;
//    }
//
//    ui->progressBar->setValue(ui->progressBar->value() + 1);
}
